package org.nterlearning.datamodel.catalog.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import org.nterlearning.datamodel.catalog.model.CourseImage;
import org.nterlearning.datamodel.catalog.model.CourseImageModel;

import java.io.Serializable;

import java.sql.Types;

/**
 * The base model implementation for the CourseImage service. Represents a row in the &quot;CATALOG_CourseImage&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link org.nterlearning.datamodel.catalog.model.CourseImageModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link CourseImageImpl}.
 * </p>
 *
 * @author Brian Wing Shun Chan
 * @see CourseImageImpl
 * @see org.nterlearning.datamodel.catalog.model.CourseImage
 * @see org.nterlearning.datamodel.catalog.model.CourseImageModel
 * @generated
 */
public class CourseImageModelImpl extends BaseModelImpl<CourseImage>
    implements CourseImageModel {
    /*
     * NOTE FOR DEVELOPERS:
     *
     * Never modify or reference this class directly. All methods that expect a course image model instance should use the {@link org.nterlearning.datamodel.catalog.model.CourseImage} interface instead.
     */
    public static final String TABLE_NAME = "CATALOG_CourseImage";
    public static final Object[][] TABLE_COLUMNS = {
            { "courseImageId", Types.BIGINT },
            { "courseId", Types.BIGINT },
            { "orderWeight", Types.DOUBLE },
            { "language", Types.VARCHAR },
            { "imageId", Types.BIGINT },
            { "alternateText", Types.VARCHAR },
            { "sourceImageUrl", Types.VARCHAR },
            { "mimeType", Types.VARCHAR }
        };
    public static final String TABLE_SQL_CREATE = "create table CATALOG_CourseImage (courseImageId LONG not null primary key,courseId LONG,orderWeight DOUBLE,language VARCHAR(10) null,imageId LONG,alternateText VARCHAR(3999) null,sourceImageUrl VARCHAR(3999) null,mimeType VARCHAR(50) null)";
    public static final String TABLE_SQL_DROP = "drop table CATALOG_CourseImage";
    public static final String ORDER_BY_JPQL = " ORDER BY courseImage.orderWeight ASC";
    public static final String ORDER_BY_SQL = " ORDER BY CATALOG_CourseImage.orderWeight ASC";
    public static final String DATA_SOURCE = "liferayDataSource";
    public static final String SESSION_FACTORY = "liferaySessionFactory";
    public static final String TX_MANAGER = "liferayTransactionManager";
    public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.entity.cache.enabled.org.nterlearning.datamodel.catalog.model.CourseImage"),
            true);
    public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.finder.cache.enabled.org.nterlearning.datamodel.catalog.model.CourseImage"),
            true);
    public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.column.bitmask.enabled.org.nterlearning.datamodel.catalog.model.CourseImage"),
            true);
    public static long COURSEID_COLUMN_BITMASK = 1L;
    public static long LANGUAGE_COLUMN_BITMASK = 2L;
    public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
                "lock.expiration.time.org.nterlearning.datamodel.catalog.model.CourseImage"));
    private static ClassLoader _classLoader = CourseImage.class.getClassLoader();
    private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
            CourseImage.class
        };
    private long _courseImageId;
    private long _courseId;
    private long _originalCourseId;
    private boolean _setOriginalCourseId;
    private double _orderWeight;
    private String _language;
    private String _originalLanguage;
    private long _imageId;
    private String _alternateText;
    private String _sourceImageUrl;
    private String _mimeType;
    private transient ExpandoBridge _expandoBridge;
    private long _columnBitmask;
    private CourseImage _escapedModelProxy;

    public CourseImageModelImpl() {
    }

    public long getPrimaryKey() {
        return _courseImageId;
    }

    public void setPrimaryKey(long primaryKey) {
        setCourseImageId(primaryKey);
    }

    public Serializable getPrimaryKeyObj() {
        return new Long(_courseImageId);
    }

    public void setPrimaryKeyObj(Serializable primaryKeyObj) {
        setPrimaryKey(((Long) primaryKeyObj).longValue());
    }

    public Class<?> getModelClass() {
        return CourseImage.class;
    }

    public String getModelClassName() {
        return CourseImage.class.getName();
    }

    public long getCourseImageId() {
        return _courseImageId;
    }

    public void setCourseImageId(long courseImageId) {
        _courseImageId = courseImageId;
    }

    public long getCourseId() {
        return _courseId;
    }

    public void setCourseId(long courseId) {
        _columnBitmask |= COURSEID_COLUMN_BITMASK;

        if (!_setOriginalCourseId) {
            _setOriginalCourseId = true;

            _originalCourseId = _courseId;
        }

        _courseId = courseId;
    }

    public long getOriginalCourseId() {
        return _originalCourseId;
    }

    public double getOrderWeight() {
        return _orderWeight;
    }

    public void setOrderWeight(double orderWeight) {
        _columnBitmask = -1L;

        _orderWeight = orderWeight;
    }

    public String getLanguage() {
        if (_language == null) {
            return StringPool.BLANK;
        } else {
            return _language;
        }
    }

    public void setLanguage(String language) {
        _columnBitmask |= LANGUAGE_COLUMN_BITMASK;

        if (_originalLanguage == null) {
            _originalLanguage = _language;
        }

        _language = language;
    }

    public String getOriginalLanguage() {
        return GetterUtil.getString(_originalLanguage);
    }

    public long getImageId() {
        return _imageId;
    }

    public void setImageId(long imageId) {
        _imageId = imageId;
    }

    public String getAlternateText() {
        if (_alternateText == null) {
            return StringPool.BLANK;
        } else {
            return _alternateText;
        }
    }

    public void setAlternateText(String alternateText) {
        _alternateText = alternateText;
    }

    public String getSourceImageUrl() {
        if (_sourceImageUrl == null) {
            return StringPool.BLANK;
        } else {
            return _sourceImageUrl;
        }
    }

    public void setSourceImageUrl(String sourceImageUrl) {
        _sourceImageUrl = sourceImageUrl;
    }

    public String getMimeType() {
        if (_mimeType == null) {
            return StringPool.BLANK;
        } else {
            return _mimeType;
        }
    }

    public void setMimeType(String mimeType) {
        _mimeType = mimeType;
    }

    public long getColumnBitmask() {
        return _columnBitmask;
    }

    @Override
    public CourseImage toEscapedModel() {
        if (_escapedModelProxy == null) {
            _escapedModelProxy = (CourseImage) ProxyUtil.newProxyInstance(_classLoader,
                    _escapedModelProxyInterfaces,
                    new AutoEscapeBeanHandler(this));
        }

        return _escapedModelProxy;
    }

    @Override
    public ExpandoBridge getExpandoBridge() {
        if (_expandoBridge == null) {
            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
                    CourseImage.class.getName(), getPrimaryKey());
        }

        return _expandoBridge;
    }

    @Override
    public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
        getExpandoBridge().setAttributes(serviceContext);
    }

    @Override
    public Object clone() {
        CourseImageImpl courseImageImpl = new CourseImageImpl();

        courseImageImpl.setCourseImageId(getCourseImageId());
        courseImageImpl.setCourseId(getCourseId());
        courseImageImpl.setOrderWeight(getOrderWeight());
        courseImageImpl.setLanguage(getLanguage());
        courseImageImpl.setImageId(getImageId());
        courseImageImpl.setAlternateText(getAlternateText());
        courseImageImpl.setSourceImageUrl(getSourceImageUrl());
        courseImageImpl.setMimeType(getMimeType());

        courseImageImpl.resetOriginalValues();

        return courseImageImpl;
    }

    public int compareTo(CourseImage courseImage) {
        int value = 0;

        if (getOrderWeight() < courseImage.getOrderWeight()) {
            value = -1;
        } else if (getOrderWeight() > courseImage.getOrderWeight()) {
            value = 1;
        } else {
            value = 0;
        }

        if (value != 0) {
            return value;
        }

        return 0;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }

        CourseImage courseImage = null;

        try {
            courseImage = (CourseImage) obj;
        } catch (ClassCastException cce) {
            return false;
        }

        long primaryKey = courseImage.getPrimaryKey();

        if (getPrimaryKey() == primaryKey) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        return (int) getPrimaryKey();
    }

    @Override
    public void resetOriginalValues() {
        CourseImageModelImpl courseImageModelImpl = this;

        courseImageModelImpl._originalCourseId = courseImageModelImpl._courseId;

        courseImageModelImpl._setOriginalCourseId = false;

        courseImageModelImpl._originalLanguage = courseImageModelImpl._language;

        courseImageModelImpl._columnBitmask = 0;
    }

    @Override
    public CacheModel<CourseImage> toCacheModel() {
        CourseImageCacheModel courseImageCacheModel = new CourseImageCacheModel();

        courseImageCacheModel.courseImageId = getCourseImageId();

        courseImageCacheModel.courseId = getCourseId();

        courseImageCacheModel.orderWeight = getOrderWeight();

        courseImageCacheModel.language = getLanguage();

        String language = courseImageCacheModel.language;

        if ((language != null) && (language.length() == 0)) {
            courseImageCacheModel.language = null;
        }

        courseImageCacheModel.imageId = getImageId();

        courseImageCacheModel.alternateText = getAlternateText();

        String alternateText = courseImageCacheModel.alternateText;

        if ((alternateText != null) && (alternateText.length() == 0)) {
            courseImageCacheModel.alternateText = null;
        }

        courseImageCacheModel.sourceImageUrl = getSourceImageUrl();

        String sourceImageUrl = courseImageCacheModel.sourceImageUrl;

        if ((sourceImageUrl != null) && (sourceImageUrl.length() == 0)) {
            courseImageCacheModel.sourceImageUrl = null;
        }

        courseImageCacheModel.mimeType = getMimeType();

        String mimeType = courseImageCacheModel.mimeType;

        if ((mimeType != null) && (mimeType.length() == 0)) {
            courseImageCacheModel.mimeType = null;
        }

        return courseImageCacheModel;
    }

    @Override
    public String toString() {
        StringBundler sb = new StringBundler(17);

        sb.append("{courseImageId=");
        sb.append(getCourseImageId());
        sb.append(", courseId=");
        sb.append(getCourseId());
        sb.append(", orderWeight=");
        sb.append(getOrderWeight());
        sb.append(", language=");
        sb.append(getLanguage());
        sb.append(", imageId=");
        sb.append(getImageId());
        sb.append(", alternateText=");
        sb.append(getAlternateText());
        sb.append(", sourceImageUrl=");
        sb.append(getSourceImageUrl());
        sb.append(", mimeType=");
        sb.append(getMimeType());
        sb.append("}");

        return sb.toString();
    }

    public String toXmlString() {
        StringBundler sb = new StringBundler(28);

        sb.append("<model><model-name>");
        sb.append("org.nterlearning.datamodel.catalog.model.CourseImage");
        sb.append("</model-name>");

        sb.append(
            "<column><column-name>courseImageId</column-name><column-value><![CDATA[");
        sb.append(getCourseImageId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>courseId</column-name><column-value><![CDATA[");
        sb.append(getCourseId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>orderWeight</column-name><column-value><![CDATA[");
        sb.append(getOrderWeight());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>language</column-name><column-value><![CDATA[");
        sb.append(getLanguage());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>imageId</column-name><column-value><![CDATA[");
        sb.append(getImageId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>alternateText</column-name><column-value><![CDATA[");
        sb.append(getAlternateText());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>sourceImageUrl</column-name><column-value><![CDATA[");
        sb.append(getSourceImageUrl());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>mimeType</column-name><column-value><![CDATA[");
        sb.append(getMimeType());
        sb.append("]]></column-value></column>");

        sb.append("</model>");

        return sb.toString();
    }
}
